package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Test2 {
    public static void main(String[] args) {
        UserInfo userInfo=InputUtil.getInputObject(new UserInfo(),"删除","删除");
        try(Connection connection=DBUtil.getConnection();) {
            String sql="DELETE FROM userinfo " +
                    "WHERE username=?";
            PreparedStatement preparedStatement=connection.prepareStatement(sql);
            preparedStatement.setString(1, userInfo.getUsername());
            int num=preparedStatement.executeUpdate();
            /*if (num>0){
                System.out.println("成功");
            }else{
                System.out.println("失败");
            }*/
            System.out.println(num>0?"成功":"失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
